package com.wushijia.test;

import java.util.stream.Stream;

public class ParallelStreams {
  //并行流计算
  public static long sequentialSum(long n) {
    //sequential：顺序执行；parallel：并行执行
    return Stream.iterate(1L, i -> i + 1).limit(n).parallel().reduce(0L, Long::sum);
  }
}
